# -*- codeing = utf-8 -*-
# @Time : 2021/3/4 21:24
# @Atuthor: 朱朱
# @File: 182tcp服务端.py
# @Software: PyCharm
import socket

# 1. 建立连接
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# 2. 绑定ip和端口号
s.bind(('127.0.0.1', 9090))

# 3. 建立监听
s.listen(1024)

# 4.接收请求
x = s.accept()

# 5.提取请求地址和套接字
client_socket, client_addr = x

# 5.接收数据
data = client_socket.recv(1024)
print('接收到了{}客户端{}端口号发送的数据，内容是:{}'.format(client_addr[0], client_addr[1], data.decode('gbk')))


